package com.wwd.statemachine.enums;

import lombok.Getter;

@Getter
public enum OrderFactoryStatus {
    WAIT_PAYMENT(1, "待支付"),
    WAIT_DELIVER(2, "待发货"),
    WAIT_RECEIVE(3, "待收货"),
    FINISH(4, "已完成"),
    ;
    private final Integer key;
    private final String desc;
    OrderFactoryStatus(Integer key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public static OrderFactoryStatus getByKey(Integer key) {
        for (OrderFactoryStatus e : values()) {
            if (e.getKey().equals(key)) {
                return e;
            }
        }
        throw new RuntimeException("enum not exists.");
    }
}
